//
//  HykHomeTitleButton.swift
//  sinaWeiBo
//
//  Created by hyk on 15/11/29.
//  Copyright © 2015年 hyk. All rights reserved.
//

import UIKit

class HykHomeTitleButton: UIButton {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //构造方法
    init(title: String){
        super.init(frame: CGRectZero)
        //设置文字
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        //设置图片
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        
        self.sizeToFit()
    
    
    }

        /// 系统调用
    override func layoutSubviews() {
         // 一定要调用父类的方法,不然子控件都看不到了
        super.layoutSubviews()
        
        //将标题移动到最左边
        titleLabel?.frame.origin.x = 0
        //将图片移动到标题的后边
        imageView?.frame.origin.x = (titleLabel?.frame.width)! + 3
        
    }
}
